﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo15_1_1
{
    internal class Program
    {
        public static Person person = new Person();
        public static Student student = new Student();
        static void Main(string[] args)
        {
            Task.Run(() => {
                lock (person)
                {
                    Console.WriteLine("进入Person");
                    lock (student)
                    {
                        Console.WriteLine($"{Environment.CurrentManagedThreadId} student lock");
                        Debugger.Break();
                    }
                }


            });

            Task.Run(() => {
                lock (student)
                {
                    Console.WriteLine("student");
                    lock (person)
                    {
                        Console.WriteLine($"{Environment.CurrentManagedThreadId} person lock");
                        Debugger.Break();
                    }
                }


            });
            Console.ReadLine();
        }
    }
    public class Person { }
    public class Student { }
}
